/*
 * base_module.h
 * This file is part of OpenAnimator
 *
 * Copyright (C) 2008 - Abhinav Lele
 *
 * OpenAnimator is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OpenAnimator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenAnimator; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 */
#include "common.h"


#ifndef __OA_BASE_MODULE_H__
#define __OA_BASE_MODULE_H__

 
 
class BaseModule { /**< tag -> fnname mapping lua automation module to be used by parser,renderer,etc */
	protected:
		map<string,string,ltstr_stl> mapping_tag_fn;
	public:
	
	int LUA_set_mapping(lua_State *L) {/**< set operation for mapping_tag_fn \param map_target \param map_fnname \return <i>Success</i> 1 <i>Error</i> no value */ 
		M("LUA_set_mapping")
		if(!(lua_isstring(L,ARG2_1) && lua_isstring(L,ARG2_2))) return 0;
		string s1 = string(lua_tostring(L,ARG2_1)) , s2 = string(lua_tostring(L,ARG2_2));
		mapping_tag_fn[s1] = s2;
		lua_pushnumber(L,1); 
		return 1;
	}

	int LUA_get_mapping(lua_State *L) {/**< get operation for mapping_tag_fn map_target*/ 
		if(!lua_isstring(L,ARG1_1)) return 0;
		string s1 = string(lua_tostring(L,ARG1_1));
		map<string,string,ltstr_stl>::iterator iter = mapping_tag_fn.find(s1);
		if( iter == mapping_tag_fn.end()) return 0;
		lua_pushstring(L,iter->second.c_str());
		return 1;
	}
	
};




#endif

